<?php

$TOTALFEATURED = get_option("display_homepage_num");
if($TOTALFEATURED == ""){ $TOTALFEATURED = 9; }
?> 

<?php if(get_option("display_featuredbox") ==1){  include_once(FilterPath()."/wp-content/themes/shopperpress/_featured.php"); }   ?>

<div style="clear:both;"></div>


<?php if($GLOBALS['shopperpress']['account'] !="no"){?>

<?php global $user_ID; if ( $user_ID ) : ?>

<?php else : ?> 

<h1 class="ItemBoxTop StopTop" style="margin-top:0px;"><b class="ItemLineHeight"><?php echo SPEC($GLOBALS['_LANG']['_home1']) ?></b></h1>

<div class="ItemBox StopTop">	
<div class="inner">
	<div style="float:left; width:300px;"><a href="wp-login.php?action=login" title="login"><img src="<?php bloginfo('template_url'); ?>/images/home1.gif" alt="login" /></a></div>
	<div style="float:left; width:300px;"><a href="wp-login.php?action=register" title="register"><img src="<?php bloginfo('template_url'); ?>/images/home2.gif" alt="register"  /></a></div>
	<div style="clear:both;"></div>
</div>
</div>

<?php endif; ?>

<?php } ?>


<?php if(get_option("display_home_hotsell") !="no"){ ?>
<h1 class="ItemBoxTop" <?php if($GLOBALS['shopperpress']['account'] != "no"){ if ( $user_ID ) : else :?>style="margin-top:20px;"<?php endif; }elseif(get_option("display_featuredbox") !=1){ ?> style="margin-top:0px;"<?php } ?>>
<b class="ItemLineHeight"><?php echo SPEC($GLOBALS['_LANG']['_home2']) ?></b></h1>

<div class="ItemBox">
<div class="inner">
	<div id="gallerycontent">
	<?php 
	
	$HI = get_option("display_hotselling_items");
	if($HI ==""){	
		$countRemains = $TOTALFEATURED;	
	}else{	
		$hotitems = explode(",",$HI); 
		$countRemains = $TOTALFEATURED - count($hotitems);	
	}

 
	if($countRemains > 0){
	$data = shopperPress_featured($countRemains);
 
	$i=1; while($i < $countRemains){ ?>
	
		<div class="thumb">
        <div style="height:130px; overflow:hidden;"><center>
			<a href="<?php echo $data[$i]['link']; ?>" rel="bookmark">
            	<img src="<?php echo SPImage($data[$i]['image']); ?>" alt="<?php echo str_replace("-","",$data[$i]['title']); ?>"/>
            </a>
		</center></div>	
            <p class="themelabel">
                <a href="<?php echo $data[$i]['link']; ?>" style="text-decoration:none;">
                    <strong><?php echo substr(str_replace("-"," ",$data[$i]['title']),0,33); ?></strong>
                </a>
            </p>
		 
		</div>
				
		<?php $i++; } } ?>	
	
		<?php if(is_array($hotitems) && !empty($hotitems)){ foreach($hotitems as $hot){ if(is_numeric($hot)){  
	 
		$featured = get_post( $hot );
	  
		$FeaturedImage = get_post_meta($featured->ID, "thumbnail", true);
	
		if($FeaturedImage==""){
		$FeaturedImage = get_post_meta($featured->ID, "image", true);
		}
	 
		?>	
		<div class="thumb">
        	<div style="height:130px; overflow:hidden;"><center>
            <a href="<?php echo get_permalink($hot); ?>" rel="bookmark">
                <img src="<?php echo SPImage($FeaturedImage); ?>" alt="<?php echo str_replace("-","",$featured->post_title); ?>" />
             </a>
             </center></div>    
            <p class="themelabel">            
				<a href="<?php echo get_permalink($hot); ?>" style="text-decoration:none;">
					<strong><?php echo substr(str_replace("-"," ",$featured->post_title),0,33); ?></strong>
				</a>            
            </p>			 
		</div>
	
	<?php } } } ?>



	</div>
	<div style="clear:both;"></div>
</div>
</div>

<?php } ?>

<?php if(get_option("display_home_recent") !="no"){ ?>

<h1 class="ItemBoxTop" ><b class="ItemLineHeight"><?php echo SPEC($GLOBALS['_LANG']['_home3']) ?></b></h1>

<div class="ItemBox">
<div class="inner">

<div id="gallerycontent1">
<?php $data = shopperPress_featured($TOTALFEATURED,"ID");
$i=1; while($i < $TOTALFEATURED){ ?>

	<div class="thumb">
     <div style="height:130px; overflow:hidden;"><center>
		<a href="<?php echo $data[$i]['link']; ?>" rel="bookmark">
			<img src="<?php echo SPImage($data[$i]['image'],"m"); ?>" alt="<?php echo $data[$i]['title']; ?>" />
		</a>
	</center>
	</div>
	<p class="themelabel">    
			<a href="<?php echo $data[$i]['link']; ?>" style="text-decoration:none;">
				<strong><?php echo substr(str_replace("-"," ",$data[$i]['title']),0,33); ?></strong>
			</a>    
	</p>	 
	</div>
			
<?php  $i++; } ?>	
</div>
<div style="clear:both;"></div>
</div>
</div>
<?php } ?> 